// import axios from 'axios'
import { Session } from '/@/utils/storage';
/**
 * 自定义上传图片插件
 */
class MyUploadAdapter {
	constructor(loader) {
		this.loader = loader;
	}
	async upload() {
		console.log('this.loader', this.loader);
		const data = new FormData();
		data.append('file', await this.loader.file);
		data.append('bucketName', 'homepage');
		const res = await axios({
			url: `/api/admin/sys-file/upload2`,
			headers: {
				Authorization: 'Bearer ' + Session.getToken(),
			},
			method: 'POST',
			data,
		});
		// 后台返回数据：
		// {"code":0,"msg":"success","data":{"url":"/upload/struts2.jpeg"}}
		// 方法返回数据格式： {default: "url"}
		return {
			default: 'http://82.157.235.89:19999' + res.data.data.url,
		};
	}
}
export default MyUploadAdapter;
